﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace server.app.lib
{
    public class Hero : Object
    {
        public string AtStarId { get { return World.HeroManager.GetAtStarId(this); } }
        public string AtSpaceId { get { return World.HeroManager.GetAtSpaceId(this); } }
        public string FactionId { get { return World.HeroManager.GetFactionId(this); } }
        public int LocX { get { return World.HeroManager.GetLocX(this); } }
        public int LocY { get { return World.HeroManager.GetLocY(this); } }
        public int Speed { get { return World.HeroManager.GetSpeed(this); } }

        public Hero(World world, comm.objst.ObjType objType, string dObjectId, string objectId)
            : base(world, objType, dObjectId, objectId)
        {
        }

        protected override void OnSetLoc()
        {
            World.HeroManager.SetLoc(this, SObject.LocX, SObject.LocY);
            base.OnSetLoc();
        }
        protected override void OnBeginMove()
        {
            Action.Exec(comm.objst.ObjActionType.MOVE.ToString());
            base.OnBeginMove();
        }
        protected override void OnEndMove()
        {
            Action.Exec(comm.objst.ObjActionType.IDLE.ToString());
            base.OnEndMove();
        }
        protected override void OnEnterSpace(Space space)
        {
            SObject.MoveSpeed = Speed;
            World.HeroManager.SetAtStarId(this, SObject.Space.StarId);
            World.HeroManager.SetAtSpaceId(this, SObject.Space.SpaceId);
            base.OnEnterSpace(space);
        }
    }

    public class Unit : Object
    {
        public int Speed { get { return World.UnitManager.GetSpeed(this); } }

        public Unit(World world, comm.objst.ObjType objType, string dObjectId, string objectId)
            : base(world, objType, dObjectId, objectId)
        {
        }

        protected override void OnEnterSpace(Space space)
        {
            SObject.MoveSpeed = Speed;
            base.OnEnterSpace(space);
        }
    }

    public class Monster : Object
    {
        public Monster(World world, comm.objst.ObjType objType, string dObjectId, string objectId)
            : base(world, objType, dObjectId, objectId)
        {
        }
    }
}
